import React, { forwardRef, useRef } from 'react'
// function Son (){
//     return <input type='text'/>
// }
const Son = forwardRef((props, ref) => {
  return <input type='text' ref={ref} />
})
export default function ForwardRefApp() {
  const sonRef = useRef(null)
  const hanleClick = () => {
    console.log(sonRef,'===')
    sonRef.current.focus()
  }
  return (
    <div>
        <h1>ForwardRefApp</h1>
        <Son ref={sonRef}></Son>
        <button onClick={hanleClick}>让子组件的input聚焦</button>
    </div>
  )
}
